<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>后台管理模板</title>
    <style>
      body {
        margin: 0;
        font-family: Arial, sans-serif;
      }

      .container {
        display: grid;
        grid-template-rows: auto 1fr;
        grid-template-columns: 200px 1fr;
        height: 100vh;
        grid-template-areas:
          "header header"
          "sidebar main";
      }

      header {
        grid-area: header;
        background-color: #333;
        color: white;
        padding: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .sidebar {
        grid-area: sidebar;
        background-color: #f4f4f4;
        padding: 10px;
        transition: width 0.3s;
      }

      .sidebar.hidden {
        width: 50px;
      }

      .sidebar ul {
        list-style: none;
        padding: 0;
        margin: 0;
      }

      .sidebar li {
        margin: 10px 0;
      }

      .sidebar img {
        width: 24px;
        height: 24px;
        vertical-align: middle;
      }

      .icon-text {
        margin-left: 10px;
        display: inline;
      }

      .sidebar.hidden .icon-text {
        display: none;
      }

      main {
        grid-area: main;
        padding: 20px;
      }

      button {
        background-color: #444;
        color: white;
        border: none;
        padding: 10px;
        cursor: pointer;
      }

      button:hover {
        background-color: #555;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <header>
        <button id="toggle-sidebar">切换侧边栏</button>
        <h1>后台管理系统</h1>
      </header>
      <aside class="sidebar">
        <ul>
          <li>
            <a href="#"
              ><img src="icon1.png" alt="图标1" /><span class="icon-text"
                >菜单1</span
              ></a
            >
          </li>
          <li>
            <a href="#"
              ><img src="icon2.png" alt="图标2" /><span class="icon-text"
                >菜单2</span
              ></a
            >
          </li>
          <li>
            <a href="#"
              ><img src="icon3.png" alt="图标3" /><span class="icon-text"
                >菜单3</span
              ></a
            >
          </li>
          <!-- 更多菜单项 -->
        </ul>
      </aside>
      <main>
        <h2>内容区域</h2>
        <p>这里是内容区域。</p>
      </main>
    </div>
    <script>
      document
        .getElementById("toggle-sidebar")
        .addEventListener("click", function () {
          document.querySelector(".sidebar").classList.toggle("hidden")
        })
    </script>
  </body>
</html>
